<template>
  <div>
    <basic-container>
      <avue-form :option="option"
                 v-model="form"
                 @submit="handleSubmit"></avue-form>
    </basic-container>
  </div>
</template>

<script>
  import {getSetting, updateSetting} from "@/api/miniapp/setting";
  export default {
    data() {
      return {
        index: 0,
        option: {
            tabs: true,
            tabsActive: 1,
            group: [
              {
                label: '首页设置',
                prop: 'info',
                column: [{
                  label: '首页注册人数',
                  span: 12,
                  row: true,
                  prop: 'plan_joinnum'
                },
                {
                  label: '任务提示',
                  prop: 'tasktips',
                  span: 12,
                  row: true,
                },{
                  label: '通知信息',
                  prop: 'notice_info',
                  span: 12,
                  row: true,
                },{
                  label: "是否显示",
                  prop: "notice_status",
                  type: "radio",
                  value:'0',
                  dicData: [
                    {
                      label: "显示",
                      value: '1'
                    },
                    {
                      label: "不显示",
                      value: '0'
                    }
                  ],
                }]
              },
            ],
        },
        form: {}
      };
    },
    created() {
      this.handleWitch();
    },
    methods: {
      handleSubmit(form, done) {
          updateSetting(form).then(res => {
            if (res.data.success) {
              this.$message({
                type: "success",
                message: "修改信息成功!"
              });
            } else {
              this.$message({
                type: "error",
                message: res.data.msg
              });
            }
            done();
          }, error => {
            window.console.log(error);
            done();
          })
      },
      handleWitch() {
          getSetting().then(res => {
            const info = res.data.data[0];
            this.form = info
          });
      }
    }
  };
</script>

<style>
</style>
